import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;

import javax.swing.JLabel;

	public class JScalableLabel extends JLabel {
		private BufferedImage bi;
		private BufferedImage bialt;
		private BarCode barcode;
		float sx=1.1f;
		float sy=1.1f;
		int direction = 0;
		public Point labelLocation = new Point(0,0);
		public JScalableLabel(final BufferedImage bi, final BufferedImage bialt, float f, float g, BarCode barcode, int direction) {
			this.bi = bi;
			this.bialt = bialt;
			this.barcode = barcode;
			this.direction = direction;
			sx = f;
			sy = g;
		}

		public void setScaling(float sx, float sy) {
			this.sx=sx;
			this.sy=sy;
		}
		public Point getlabelLocation() {
			return this.labelLocation;
		}
		public void setlabelLocation(Point location) {
			this.labelLocation = location;
		}
		@Override
		public Dimension getPreferredSize() {
			return new Dimension(bi.getWidth(), bi.getHeight());
		}
		@Override
		protected void paintComponent(Graphics g) {
			super.paintComponent(g);
			Graphics2D g2 = (Graphics2D) g;
			AffineTransform trans = AffineTransform.getScaleInstance(sx, sy);
			g2.drawRenderedImage(bi, trans);
			
		}
		@Override
		public JScalableLabel clone() {
			JScalableLabel newLabel = new JScalableLabel(bialt,bi,sx,sy,getBarcode(),getDirection());
			newLabel.setlabelLocation(new Point(labelLocation.x,labelLocation.y));
			return newLabel;
		}

		public BarCode getBarcode() {
			return barcode;
		}

		public int getDirection() {
			return direction;
		}
	}